<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<html>
	<body>
		<% User user = UserServiceFactory.getUserService().getCurrentUser(); %>
		
		<% if( user == null ){ %>
			You need to login to your Google account, to access this page.<br />
			<a href="<%= UserServiceFactory.getUserService().createLoginURL(request.getRequestURI()) %>">Sign in</a> 
		<% }else{ %>
		
		Welcome, <b><%= user.getNickname() %></b><br />
		<div>Purchase form<br />
			<form action="/purchase" method="post">
	            <div><label for="uid">Client UID</label></div>
				<div><input type="text" name="uid" maxlength="32" /></div>
                <div><label for="uid">Company ID</label></div>
                <div><input type="text" name="cid" maxlength="32" /></div>
				<div><label for="sum">Sum (minor currency)</label></div>
				<div><input type="text" name="sum" maxlength="8" /></div>
				<div><input type="submit" name="submit" value="Calculate"></div>
			</form>
        </div>
		
		<% } %>
	</body>
</html>